Fix gbfputcstr when using non UTF-8 encoding. (#348)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 14 May 2019 14:06:59 +0000 (08:06 -0600)
committerGitHub <noreply@github.com>
Tue, 14 May 2019 14:06:59 +0000 (08:06 -0600)
commit1acc843a3ed324628c8935d806b69ce93062f27f
tree81870514452b827026531ceaa5cf07b18afb745c
parentee2fa858b451133d10815fd1fe2472af1e6b74fa
Fix gbfputcstr when using non UTF-8 encoding. (#348)

* Fix gbfputcstr when using non UTF-8 encoding.

This restores gbfputcstr from 75d8ec00f^.
That change could result in implicit conversion of
char* data that was specifically encoded as required for
a format to UTF-16, and then explicitly converted from UTF-16
to UTF-8.  While this was inefficient it could also
result in corruption when the data to be written was encoded
in something other than UTF-8.
For example, the Latin1 encoded 'รถ' is '\xf6' will
be converted to the UTF-16 replacement character, and that will
be converter to the UTF-8 replacement character, not the original
character.

This resolves a mystery that was noted in the gdb test where some
strings where corrupted when writing gdb versions 1 and 2.

Instead of using function overloading I deleted the version of
gbfputcstr that accepted a QString to write, forcing the user
to specifically convert the data as appropriate.

* increase accuracy of GPS_Math_Deg_To_Semi.

Use rounding of the calculated floating point value before
conversion to an integer to improve accuracy.
This minimizes
abs(GPS_Math_Semi_to_Deg(GPS_Math_Deg_To_Semi(fpvalue)) - fpvalue).
This allows us do some round trip testing from formats that use
a textual representations of degrees, e.g. gpx, to a binary
format that stores integer represetations of angles in semicircle
units, and back.

It is still possible for round trip differences to occur,
but in all our test cases this hasn't been observed.
The value, the number of decimal places printed for the textual
representation, and the size of floating point variables can
all influence this.

Two GPSBabel generated binary reference files are updated.  All changes
in these files are 1 bit changes in latitude or longitude values as
can be expected from the difference between truncation and rounding.

Two GPSBabel generated gpx reference files are deleted as the source
of the round trip test can be compared to the output now.

A gdb test comparison is now enabled as the round trip results now
match.

* enhance gdb test.

adding a roundtrip test with gdb version 3.
easygps.cc
gbfile.cc
gbfile.h
jeeps/gpsmath.cc
lmx.cc
reference/garmin_gpi2.gpx [deleted file]
reference/garmin_gpi_category~gpx.gpi
reference/garmin_gpi_encoding2.gpi.gpx [deleted file]
reference/netstumbler.mps
testo.d/garmin_gpi.test
testo.d/gdb.test